package com.stu.web.sevlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
	@WebServlet("/getcookie")
public class GetCookieServlet extends HttpServlet{
		@Override
		protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			 Cookie[] cookies = req.getCookies();
			 if (null != cookies) {
				 for (Cookie cookie : cookies) {
						String name = cookie.getName();
						String value = cookie.getValue(); 
						System.out.println("cookie name: " + name);
						System.out.println("cookie value: " + value);
					}
				}
			}
			
		}
	

